import os
import sys
import mysql.connector
from PyQt5.QtWidgets import QApplication, QMainWindow
from login import Ui_Login  # login 首页命名文件
from Login_DL import Ui_login_DL  # Login_DL 登录界面文件
from register import Ui_register_2  # register 登录界面文件
from web_DL import Ui_web_DL  # web_DL 微博登录界面文件
from qq_DL import Ui_QQ_DL  # qq_DL QQ登录界面文件
from wx_DL import Ui_wx_DL  # wx_DL 微信登录界面文件
from shouye import Ui_shouye  # shouye 主界面文件


# 首页
class login(QMainWindow, Ui_Login):
    def __init__(self, parent=None):
        super(login, self).__init__(parent)
        self.setupUi(self)

    def Open(self):
        self.show()


# 登录页面
class Login_DL(QMainWindow, Ui_login_DL):
    def __init__(self, parent=None):
        super(Login_DL, self).__init__(parent)
        self.setupUi(self)

    def Open(self):
        self.show()


# 注册页面
class register(QMainWindow, Ui_register_2):
    def __init__(self, parent=None):
        super(register, self).__init__(parent)
        self.setupUi(self)

    def Open(self):
        self.show()


# 微博页面
class web_DL(QMainWindow, Ui_web_DL):
    def __init__(self, parent=None):
        super(web_DL, self).__init__(parent)
        self.setupUi(self)

    def Open(self):
        self.show()


# QQ页面
class qq_DL(QMainWindow, Ui_QQ_DL):
    def __init__(self, parent=None):
        super(qq_DL, self).__init__(parent)
        self.setupUi(self)

    def Open(self):
        self.show()


# 微信页面
class wx_DL(QMainWindow, Ui_wx_DL):
    def __init__(self, parent=None):
        super(wx_DL, self).__init__(parent)
        self.setupUi(self)

    def Open(self):
        self.show()


# 主界面
class shouye(QMainWindow, Ui_shouye):
    def __init__(self, parent=None):
        super(shouye, self).__init__(parent)
        self.setupUi(self)
# 页面跳转
        self.pushButton.clicked.connect(self.display_page1)      # 点击打开音乐推荐页面
        self.pushButton_2.clicked.connect(self.display_page2)    # 点击乐库打开页面
        self.pushButton_3.clicked.connect(self.display_page3)    # 点击歌单打开页面
        self.pushButton_10.clicked.connect(self.display_page4)   # 点击频道打开页面
        self.pushButton_11.clicked.connect(self.display_page5)   # 点击视频打开页面
        self.pushButton_12.clicked.connect(self.display_page6)   # 点击直播打开页面
        self.pushButton_13.clicked.connect(self.display_page7)   # 点击我的收藏打开页面
        self.pushButton_14.clicked.connect(self.display_page8)   # 点击我的频道打开页面
        self.pushButton_15.clicked.connect(self.display_page9)   # 点击本地与下载打开页面
        self.pushButton_16.clicked.connect(self.display_page10)  # 点击音乐云盘打开页面
        self.pushButton_17.clicked.connect(self.display_page11)  # 点击已购音乐打开页面
        self.pushButton_18.clicked.connect(self.display_page12)  # 点击最近播放打开页面
        self.pushButton_19.clicked.connect(self.display_page13)  # 点击默认列表打开页面

        self.stackedWidget.setCurrentIndex(0)  # 初始化展示页面1
# 页面索引
    def display_page1(self):
        self.stackedWidget.setCurrentIndex(0)

    def display_page2(self):
        self.stackedWidget.setCurrentIndex(1)

    def display_page3(self):
        self.stackedWidget.setCurrentIndex(2)

    def display_page4(self):
        self.stackedWidget.setCurrentIndex(3)

    def display_page5(self):
        self.stackedWidget.setCurrentIndex(4)

    def display_page6(self):
        self.stackedWidget.setCurrentIndex(5)

    def display_page7(self):
        self.stackedWidget.setCurrentIndex(6)

    def display_page8(self):
        self.stackedWidget.setCurrentIndex(7)

    def display_page9(self):
        self.stackedWidget.setCurrentIndex(8)

    def display_page10(self):
        self.stackedWidget.setCurrentIndex(9)

    def display_page11(self):
        self.stackedWidget.setCurrentIndex(10)

    def display_page12(self):
        self.stackedWidget.setCurrentIndex(11)

    def display_page13(self):
        self.stackedWidget.setCurrentIndex(12)

    def Open(self):
        self.show()


if __name__ == '__main__':
    app = QApplication(sys.argv)

    # 实例化页面
    login = login()  # 首页
    Login_DL = Login_DL()  # 登录
    register = register()  # 注册
    web_DL = web_DL()  # 微博登录
    qq_DL = qq_DL()  # QQ登录
    wx_DL = wx_DL()  # 微信登录
    shouye = shouye()  # 音乐首页界面

    # 将按钮与页面打开连接起来
    login.pushButton.clicked.connect(Login_DL.Open)  # 首页登录按钮打开登录界面
    login.pushButton_2.clicked.connect(register.Open)  # 首页注册按钮打开登录界面
    register.pushButton.clicked.connect(Login_DL.Open)  # 注册页面确认按钮打开登录界面
    register.pushButton_2.clicked.connect(Login_DL.Open)  # 注册页面取消按钮打开登录界面
    login.pushButton_3.clicked.connect(web_DL.Open)  # 首页微博按钮打开微博登录界面
    web_DL.pushButton_wb.clicked.connect(shouye.Open)  # 微博登录界面确认按钮打开主界面
    web_DL.pushButton_wb2.clicked.connect(Login_DL.Open)  # 微博登录界面点击取消打开用户登录界面
    login.pushButton_4.clicked.connect(qq_DL.Open)  # 首页QQ按钮打开QQ登录界面
    qq_DL.pushButton_qq1.clicked.connect(shouye.Open)  # QQ登录界面确认按钮打开主界面
    qq_DL.pushButton_qq2.clicked.connect(Login_DL.Open)  # QQ登录界面取消按钮打开用户登录界面
    login.pushButton_5.clicked.connect(wx_DL.Open)  # 首页微信按钮打开微信登录界面
    wx_DL.pushButton_wx1.clicked.connect(shouye.Open)  # 微信登录界面确认按钮打开主界面
    wx_DL.pushButton_wx2.clicked.connect(Login_DL.Open)  # 微信登录界面取消按钮打开用户登录界面
    Login_DL.pushButton.clicked.connect(shouye.Open)  # 用户登录界面确认按钮打开主界面
    Login_DL.pushButton_2.clicked.connect(register.Open)  # 用户登录界面取消按钮打开首页

    login.show()
    sys.exit(app.exec_())
